//#include "StdAfx.h"
#include "base_addr.h"
#include "base_common_func.h"

CCommunicationAddr::CCommunicationAddr(void)
{
	 // lcy note 2008_10_10:
// 	m_strDomain = "";
//  	m_strIp     = "192.168.0.240";
	m_uPort     = 0;//3330;
	m_cIpType   = 0;//4;
    m_cNetType  = 0;
}
CCommunicationAddr::CCommunicationAddr( const CCommunicationAddr & addr )
{
	m_cIpType   = addr.m_cIpType;
	m_cNetType  = addr.m_cNetType;
	m_uPort     = addr.m_uPort;
	m_strIp     = addr.m_strIp;
	m_strDomain = addr.m_strDomain;
}
CCommunicationAddr::~CCommunicationAddr(void)
{
}
bool CCommunicationAddr::operator==( const CCommunicationAddr & addr )
{
	bool bRes = ( (m_strIp==addr.m_strIp) && (m_uPort==addr.m_uPort) );
	return bRes;
}
CCommunicationAddr & CCommunicationAddr::operator=( const CCommunicationAddr & addr )
{
	this->m_cIpType   = addr.m_cIpType;
	this->m_cNetType  = addr.m_cNetType;
	this->m_uPort     = addr.m_uPort;
	this->m_strIp     = addr.m_strIp;
	this->m_strDomain = addr.m_strDomain;
	return *this;
}
void CCommunicationAddr::SetPort( uint16 uPort )
{
	m_uPort = uPort;
}
void CCommunicationAddr::SetNetType( uint8 cNetType )
{
	m_cNetType = cNetType;
}
void CCommunicationAddr::SetIpType( uint8 cIpType )
{
	m_cIpType = cIpType;
}
void CCommunicationAddr::SetIp( castr_t lpszIp )
{
 	m_strIp = string(lpszIp);
}
void CCommunicationAddr::SetDomain( castr_t lpszDomain )
{
	m_strDomain = lpszDomain;
	if (m_strIp.empty() && !m_strDomain.empty())
		m_strIp = Domain2Ip(lpszDomain);
}

uint16 CCommunicationAddr::GetPort()
{
	return m_uPort;
}
uint8  CCommunicationAddr::GetNetType()
{
	return m_cNetType;
}
uint8  CCommunicationAddr::GetIpType()
{
	return m_cIpType;
}
castr_t CCommunicationAddr::GetIp()
{
 	return m_strIp.c_str();
}
castr_t CCommunicationAddr::GetDomain()
{
	return m_strDomain.c_str();
}